home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / Include / fscache.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-26  |  21.0 KB  |  537 lines

  1. /*
  2.  * fscache.h --
  3.  *
  4.  *    Declarations of interface to the Sprite file system cache. 
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/kernel/Cvsroot/kernel/fscache/fscache.h,v 9.19 92/10/26 13:55:12 mgbaker Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _FSCACHE
  19. #define _FSCACHE
  20.  
  21. #include <sync.h>
  22. #include <list.h>
  23. #include <fs.h>
  24. #include <user/time.h>
  25.  
  26. /* data structures */    
  27.  
  28.  
  29. /*
  30.  * Cache information for each file.
  31.  */
  32.  
  33. typedef struct Fscache_Attributes {
  34.     int        firstByte;    /* Cached version of desc. firstByte */
  35.     int        lastByte;    /* Cached version of desc. lastByte */
  36.     int        accessTime;    /* Cached version of access time */
  37.     int        modifyTime;    /* Cached version of modify time */
  38.     int        createTime;    /* Create time (won't change, but passed
  39.                  * to clients for use in
  40.                  * statistics-gathering) */
  41.     int        userType;    /* user advisory file type, defined in
  42.                  * user/fs.h */
  43.     /*
  44.      * The following fields are needed by Proc_Exec.
  45.      */
  46.     int        permissions;    /* File permissions */
  47.     int        uid;        /* User ID of owner */
  48.     int        gid;        /* Group Owner ID */
  49. } Fscache_Attributes;
  50.  
  51.  
  52.  
  53.  
  54. /*
  55.  * Structure to represent a cache block in the fileservers cache block 
  56.  * list and the core map list.
  57.  */
  58. typedef struct Fscache_FileInfo {
  59.     List_Links       links;       /* Links for the list of dirty files.
  60.                       THIS MUST BE FIRST in the struct */
  61.     List_Links       dirtyList;       /* List of dirty blocks for this file.
  62.                     * THIS MUST BE SECOND, see the macro
  63.                     * in fsBlockCache.c that depends on it. */
  64.     List_Links       blockList;      /* List of blocks for the file */
  65.     List_Links       indList;       /* List of indirect blocks for the file */
  66.     Sync_Lock       lock;       /* This is used to serialize cache access */
  67.     int           flags;       /* Flags to indicate the state of the
  68.                       file, defined below. */
  69.     int           version;       /* Used to verify validity of cached data */
  70.     struct Fs_HandleHeader *hdrPtr; /* Back pointer to I/O handle */
  71.     int           blocksInCache;  /* The number of blocks that this file has
  72.                       in the cache. */
  73.     int           blocksWritten;  /* The number of blocks that have been
  74.                     * written in a row without requiring a 
  75.                     * sync of the servers cache. */
  76.     int           numDirtyBlocks; /* The number of dirty blocks in the cache.*/
  77.     Sync_Condition noDirtyBlocks;  /* Notified when all write backs done. */
  78.     int           lastTimeTried;  /* Time that last tried to see if disk was
  79.                     * available for this block. */
  80.     time_t       oldestDirtyBlockTime;
  81.     Fscache_Attributes attr;       /* Local version of descriptor attributes. */
  82.     struct Fscache_Backend   *backendPtr;  
  83.             /* Routines for read/write/allocate/copy. */
  84. } Fscache_FileInfo;
  85.  
  86. /*
  87.  * Values for flags field in the Fscache_FileInfo struct.
  88.  *
  89.  *   FSCACHE_CLOSE_IN_PROGRESS    There is a close being done on this file so
  90.  *                no more delayed writes are allowed.
  91.  *   FSCACHE_SERVER_DOWN    The host that this file belongs is down.
  92.  *   FSCACHE_NO_DISK_SPACE    The domain that this file lives in has no
  93.  *                disk space.
  94.  *   FSCACHE_DOMAIN_DOWN    The domain to write to is not available.
  95.  *   FSCACHE_GENERIC_ERROR    An error occured for which we just hang onto
  96.  *                file blocks until we can write them out.
  97.  *   FSCACHE_SYNC_DONE        The server has been told to force all blocks
  98.  *                for this file to disk.
  99.  *   FSCACHE_FILE_BEING_WRITTEN    There already is a block cleaner working on
  100.  *                this process.
  101.  *   FSCACHE_FILE_ON_DIRTY_LIST    This file is on the dirty list.
  102.  *   FSCACHE_WRITE_TO_DISK    Want file forced to disk.
  103.  *   FSCACHE_FILE_NOT_CACHEABLE    This is set when files served by remote hosts
  104.  *                are no longer caching because of write sharing
  105.  *                or because the file is a directory.
  106.  *   FSCACHE_LARGE_FILE_MODE    This file is large enough such that we limit it
  107.  *                to only a few blocks in the cache.
  108.  *   FSCACHE_FILE_GONE        The file has been removed and any delayed
  109.  *                writes should be discarded.
  110.  *   FSCACHE_IS_DIR        File not cacheable because it's a directory.
  111.  *                This is used for keeping statistics.
  112.  *   FSCACHE_ALLOC_FAILED    Allocated failed due to disk full.  This
  113.  *                is used to throttle error messages.
  114.  *   FSCACHE_FILE_BEING_CLEANED
  115.  */
  116. #define    FSCACHE_CLOSE_IN_PROGRESS    0x0001
  117. #define    FSCACHE_SERVER_DOWN        0x0002
  118. #define    FSCACHE_NO_DISK_SPACE        0x0004
  119. #define FSCACHE_DOMAIN_DOWN        0x0008
  120. #define FSCACHE_GENERIC_ERROR        0x0010
  121. #define    FSCACHE_SYNC_DONE        0x0020
  122. #define FSCACHE_FILE_BEING_WRITTEN    0x0040
  123. #define    FSCACHE_FILE_ON_DIRTY_LIST    0x0080
  124. #define FSCACHE_WRITE_TO_DISK        0x0100
  125. #define FSCACHE_FILE_NOT_CACHEABLE    0x0200
  126. #define    FSCACHE_LARGE_FILE_MODE        0x0400
  127. #define FSCACHE_FILE_GONE        0x0800
  128. #define    FSCACHE_IS_DIR            0x1000
  129. #define FSCACHE_ALLOC_FAILED        0x2000
  130. #define    FSCACHE_FILE_FSYNC        0x4000
  131. #define    FSCACHE_FILE_DESC_DIRTY        0x8000
  132. #define    FSCACHE_FILE_BEING_CLEANED     0x10000
  133.  
  134. /*
  135.  * Structure to represent a cache block in the fileservers cache block 
  136.  * list and the core map list.
  137.  */
  138. typedef struct Fscache_Block {
  139.     List_Links    dirtyLinks;    /* Links to put block into list of dirty
  140.                  * blocks for the file.  THIS MUST BE FIRST 
  141.                  * in the struct. It may be used by the
  142.                  * cache backend's after a Fetch_DirtyBlock
  143.                  * call.  */
  144.     List_Links    useLinks;    /* Links to put block into list of unused 
  145.                    cache blocks or LRU list of cache blocks.
  146.                    THIS MUST BE SECOND in the struct. */
  147.     List_Links    fileLinks;    /* Links to put block into list of blocks
  148.                  * for the file.  There are two lists, either
  149.                  * regular or for indirect blocks. */
  150.     time_t timeDirtied;        /* Time in seconds that block was
  151.                    dirtied if at all. */
  152.     time_t timeReferenced;    /* Time in seconds that this block was
  153.                  * last referenced. */
  154.     Address    blockAddr;    /* Kernel virtual address where data for
  155.                    cache block is at. */
  156.     Fscache_FileInfo *cacheInfoPtr;    /* Reference to file's cache info. */
  157.     int        fileNum;    /* For consistency checks */
  158.     int        blockNum;    /* The number of this block in the file. */
  159.     int        diskBlock;    /* The block number on disk for this block. 
  160.                    For remote blocks this equals blockNum. */
  161.     int        blockSize;    /* The number of valid bytes in this block. */
  162.     int        refCount;    /* Number of times that the block is referenced.
  163.                    0 means is unreferenced. */
  164.     Sync_Condition ioDone;    /* Notified when block is unlocked after I/O */
  165.     int        flags;        /* Flags to indicate state of block. */
  166. } Fscache_Block;
  167.  
  168. /* 
  169.  * Flags for a Fscache_Block: 
  170.  * 
  171.  *   FSCACHE_BLOCK_FREE            The block is not being used.
  172.  *   FSCACHE_BLOCK_ON_DIRTY_LIST    The block is on the dirty list.
  173.  *   FSCACHE_BLOCK_BEING_WRITTEN    The block is in the process of being
  174.  *                    written to disk.
  175.  *   FSCACHE_BLOCK_DIRTY        The block contains dirty data.
  176.  *   FSCACHE_BLOCK_DELETED        This block has been deleted.  This
  177.  *                    flag is set when a block is to be
  178.  *                    invalidated after it has been cleaned.
  179.  *   FSCACHE_MOVE_TO_FRONT        After this block has finished being
  180.  *                    cleaned move it to the front of the
  181.  *                    LRU list.
  182.  *   FSCACHE_WRITE_BACK_WAIT        This block is being written out by 
  183.  *                    FsCacheWriteBack which is waiting
  184.  *                    for all such blocks to be written out.
  185.  *   FSCACHE_BLOCK_WRITE_LOCKED        This block is being modified.
  186.  *   FSCACHE_BLOCK_NEW            This block was just created.
  187.  *   FSCACHE_BLOCK_CLEANER_WAITING    The block cleaner is waiting for this
  188.  *                    block to become unlocked in order to
  189.  *                    write it out.
  190.  *   FSCACHE_NOT_MAPPED            This cache block does not have
  191.  *                    physical memory behind it.
  192.  *   FSCACHE_IND_BLOCK            This block is an indirect block.
  193.  *   FSCACHE_DESC_BLOCK            This block is a file descriptor block.
  194.  *   FSCACHE_DIR_BLOCK            This is a directory block.
  195.  *   FSCACHE_DATA_BLOCK            This is a data block.
  196.  *   FSCACHE_READ_AHEAD_BLOCK        This block was read ahead.
  197.  *   FSCACHE_IO_IN_PROGRESS        IO is in progress on this block.
  198.  *   FSCACHE_CANT_BLOCK
  199.  *   FSCACHE_DONT_BLOCK            Don't block if the cache block is
  200.  *                    already locked.    
  201.  *   FSCACHE_PIPE_BLOCK            This is a block that is permanently
  202.  *                    locked so that it can serve as the
  203.  *                    data area for a pipe. (NOT USED)
  204.  *   FSCACHE_WRITE_THRU_BLOCK        This block is being written through by
  205.  *                    the caller to Fscache_UnlockBlock.
  206.  *   FSCACHE_BLOCK_BEING_CLEANED        The block is being cleaned.
  207.  */
  208. #define    FSCACHE_BLOCK_FREE            0x000001
  209. #define    FSCACHE_BLOCK_ON_DIRTY_LIST        0x000002
  210. #define    FSCACHE_BLOCK_BEING_WRITTEN        0x000004
  211. #define    FSCACHE_BLOCK_DIRTY            0x000008
  212. #define    FSCACHE_BLOCK_DELETED            0x000010
  213. #define    FSCACHE_MOVE_TO_FRONT            0x000020
  214. #define    FSCACHE_WRITE_BACK_WAIT            0x000040
  215. #define    FSCACHE_BLOCK_WRITE_LOCKED        0x000100
  216. #define    FSCACHE_BLOCK_NEW            0x000200
  217. #define    FSCACHE_BLOCK_CLEANER_WAITING        0x000400
  218. #define    FSCACHE_NOT_MAPPED            0x000800
  219. #define    FSCACHE_IND_BLOCK            0x001000
  220. #define    FSCACHE_DESC_BLOCK            0x002000
  221. #define    FSCACHE_DIR_BLOCK            0x004000
  222. #define    FSCACHE_DATA_BLOCK            0x008000
  223. #define    FSCACHE_READ_AHEAD_BLOCK        0x010000
  224. #define    FSCACHE_IO_IN_PROGRESS            0x020000
  225. #define FSCACHE_DONT_BLOCK            0x040000
  226. #define FSCACHE_PIPE_BLOCK            0x080000
  227. #define    FSCACHE_WRITE_THRU_BLOCK        0x100000
  228. #define    FSCACHE_CANT_BLOCK            0x200000
  229. #define    FSCACHE_BLOCK_BEING_CLEANED        0x400000
  230.  
  231. /*
  232.  * Macro to get the block address field of the Fscache_Block struct.
  233.  */
  234.  
  235. #define    Fscache_BlockAddress(cacheBlockPtr) ((cacheBlockPtr)->blockAddr)
  236.  
  237. /*
  238.  * Constant to pass to Fscache_FileWriteBack, which takes block numbers as
  239.  * arguments.
  240.  */
  241. #define FSCACHE_LAST_BLOCK    -1
  242.  
  243. /*
  244.  * Constants to pass as flags to Fscache_FileWriteBack.
  245.  *
  246.  *    FSCACHE_FILE_WB_WAIT        Wait for blocks to be written back.
  247.  *    FSCACHE_WRITE_BACK_INDIRECT    Write back indirect blocks.
  248.  *    FSCACHE_WRITE_BACK_AND_INVALIDATE    Invalidate after writing back.
  249.  *    FSCACHE_WB_MIGRATION        Invalidation due to migration (for
  250.  *                    statistics purposes only).
  251.  *    FSCACHE_WRITE_BACK_DESC_ONLY     Only writeback the descriptor.
  252.  */
  253. #define FSCACHE_FILE_WB_WAIT        0x1
  254. #define    FSCACHE_WRITE_BACK_INDIRECT    0x2
  255. #define    FSCACHE_WRITE_BACK_AND_INVALIDATE    0x4
  256. #define    FSCACHE_WB_MIGRATION    0x8
  257. #define    FSCACHE_WRITE_BACK_DESC_ONLY    0x10
  258.  
  259. /*
  260.  * Constants to pass as flags to FsUnlockCacheBlock.
  261.  *
  262.  *    FSCACHE_DELETE_BLOCK        The block should be deleted when it is unlocked.
  263.  *    FSCACHE_CLEAR_READ_AHEAD   Clear the read ahead flag from the block.
  264.  *    FSCACHE_BLOCK_UNNEEDED     This block is not needed anymore.  Throw it away
  265.  *                as soon as possible.
  266.  *    FSCACHE_DONT_WRITE_THRU    Don't write this block through to disk.
  267.  *
  268.  * Also can pass one of the 4 block types defined above (0x1000 - 0x8000).
  269.  */
  270. #define    FSCACHE_DELETE_BLOCK            0x0001
  271. #define    FSCACHE_CLEAR_READ_AHEAD        0x0002
  272. #define FSCACHE_BLOCK_UNNEEDED        0x0004
  273. #define    FSCACHE_DONT_WRITE_THRU        0x0008
  274.  
  275. /*
  276.  * Flags for Fscache_Trunc
  277.  *    FSCACHE_TRUNC_DELETE    Truncate because the file is deleted.  This
  278.  *                is used to prevent delayed writes during the
  279.  *                truncation of the file.
  280.  */
  281. #define FSCACHE_TRUNC_DELETE        0x1
  282.  
  283. typedef struct Fscache_BackendRoutines {
  284.     /*
  285.      *    FooAllocate(hdrPtr, offset, bytes, flags, blockAddrPtr, newBlockPtr)
  286.      *        Fs_HandleHeader *hdrPtr;            (File handle)
  287.      *        int        offset;            (Byte offset)
  288.      *        int        bytes;            (Bytes to allocate)
  289.      *        int        flags;            (FSCACHE_DONT_BLOCK)
  290.      *        int        *blockAddrPtr;        (Returned block number)
  291.      *        Boolean        *newBlockPtr;        (TRUE if new block)
  292.      *    FooTruncate(hdrPtr, size, delete)
  293.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  294.      *        int        size;            (New size)
  295.      *        Boolean        delete;            (TRUE if file being 
  296.      *                             removed)
  297.      *    FooBlockRead(hdrPtr, blockPtr,remoteWaitPtr)
  298.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  299.      *        Fscache_Block    *blockPtr;        (Cache block to read)
  300.      *        Sync_RemoteWaiter *remoteWaitPtr;    (For remote waiting)
  301.      *    FooBlockWrite(hdrPtr, blockPtr, lastDirtyBlock)
  302.      *        Boolean        lastDirtyBlock;        (Indicates last block)
  303.      *    FooReallocBlock(data, callInfoPtr)
  304.      *        ClientData    data =     blockPtr;  (Cache block to realloc)
  305.      *        Proc_CallInfo    *callInfoPtr;    
  306.      *    FooStartWriteBack(backendPtr)
  307.      *        Fscache_Backend *backendPtr;    (Backend to start writeback.)
  308.      */ 
  309.     ReturnStatus (*allocate) _ARGS_((Fs_HandleHeader *hdrPtr, int offset,
  310.                     int numBytes, int flags, int *blockAddrPtr,
  311.                     Boolean *newBlockPtr));
  312.     ReturnStatus (*truncate) _ARGS_((Fs_HandleHeader *hdrPtr, int size, 
  313.                      Boolean delete));
  314.     ReturnStatus (*blockRead) _ARGS_((Fs_HandleHeader *hdrPtr, 
  315.                       Fscache_Block *blockPtr, 
  316.                       Sync_RemoteWaiter *remoteWaitPtr));
  317.     ReturnStatus (*blockWrite) _ARGS_((Fs_HandleHeader *hdrPtr, 
  318.                        Fscache_Block *blockPtr, int flags));
  319.     void     (*reallocBlock) _ARGS_((ClientData data, 
  320.                      Proc_CallInfo *callInfoPtr));
  321.  
  322.                 /* Second parameter is for ASPLOS only.
  323.                  * Remove when that's over. -Mary 2/15/92. */
  324.     ReturnStatus (*startWriteBack) _ARGS_((struct Fscache_Backend *backendPtr, Boolean fileFsynced));
  325. } Fscache_BackendRoutines;
  326.  
  327.  
  328. /*
  329.  * Routines and data structures defining a backend to the cache. 
  330.  */
  331. typedef struct Fscache_Backend {
  332.     List_Links    cacheLinks;    /* Used by fscacheBlocks.c to link backends
  333.                  * onto a list. Must be first in structure! */
  334.     int        flags;        /* See below. */
  335.     ClientData    clientData;    /* ClientData for the backend. */
  336.     List_Links    dirtyListHdr;   /* List of dirty files for this backend. */
  337.  
  338.     Fscache_BackendRoutines ioProcs; /* Routines for backend. */
  339. } Fscache_Backend;
  340.  
  341.  
  342. /*
  343.  * Read-ahead is used for both local and remote files that are cached.
  344.  * The following structure is used to synchronize read ahead with other I/O.
  345.  */
  346.  
  347. typedef struct Fscache_ReadAheadInfo {
  348.     Sync_Lock        lock;        /* Access to this state is monitored */
  349.     int            count;        /* Number of read aheads in progress */
  350.     Boolean        blocked;    /* TRUE if read ahead is blocked */
  351.     Sync_Condition    done;        /* Notified when there are no more read
  352.                      * aheads in progress. */
  353.     Sync_Condition    okToRead;    /* Notified when there are no more
  354.                      * conflicts with read ahead. */
  355. } Fscache_ReadAheadInfo;            /* 24 BYTES */
  356.  
  357. #define    FSCACHE_NUM_DOMAIN_TYPES    2
  358.  
  359. #ifndef CLEAN
  360. #define FSCACHE_DEBUG_PRINT(string) \
  361.     if (fsconsist_Debug) {\
  362.         printf(string);\
  363.     }
  364. #define FSCACHE_DEBUG_PRINT1(string, arg1) \
  365.     if (fsconsist_Debug) {\
  366.         printf(string, arg1);\
  367.     }
  368. #define FSCACHE_DEBUG_PRINT2(string, arg1, arg2) \
  369.     if (fsconsist_Debug) {\
  370.         printf(string, arg1, arg2);\
  371.     }
  372. #define FSCACHE_DEBUG_PRINT3(string, arg1, arg2, arg3) \
  373.     if (fsconsist_Debug) {\
  374.         printf(string, arg1, arg2, arg3);\
  375.     }
  376. #else
  377. #define FSCACHE_DEBUG_PRINT(string)
  378. #define FSCACHE_DEBUG_PRINT1(string, arg1)
  379. #define FSCACHE_DEBUG_PRINT2(string, arg1, arg2)
  380. #define FSCACHE_DEBUG_PRINT3(string, arg1, arg2, arg3)
  381. #endif not CLEAN
  382.  
  383. /*
  384.  * The cache uses a number of Proc_ServerProcs to do write-backs.
  385.  * FSCACHE_MAX_CLEANER_PROCS defines the maximum number, and this
  386.  * is used to configure the right number of Proc_ServerProcs.
  387.  */
  388. #define FSCACHE_MAX_CLEANER_PROCS    6
  389.  
  390. extern int    fscache_MaxBlockCleaners;
  391. extern int    fscache_NumReadAheadBlocks;
  392.  
  393. extern List_Links *fscacheFullWaitList;
  394.  
  395. /* procedures */
  396.  
  397. /*
  398.  * Block Cache routines. 
  399.  */
  400. extern void Fscache_WriteBack _ARGS_((unsigned int writeBackTime,
  401.             int *blocksSkippedPtr, Boolean writeBackAll));
  402. extern ReturnStatus Fscache_FileWriteBack _ARGS_((
  403.             Fscache_FileInfo *cacheInfoPtr, int firstBlock, 
  404.             int lastBlock, int flags, int *blocksSkippedPtr));
  405. extern void Fscache_FileInvalidate _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  406.             int firstBlock, int lastBlock));
  407. extern void Fscache_Empty _ARGS_((int *numLockedBlocksPtr));
  408. extern void Fscache_CheckFragmentation _ARGS_((int *numBlocksPtr, 
  409.             int *totalBytesWastedPtr, int *fragBytesWastedPtr));
  410.  
  411. extern ReturnStatus Fscache_CheckVersion _ARGS_((
  412.             Fscache_FileInfo *cacheInfoPtr, int version, 
  413.             int clientID));
  414. extern ReturnStatus Fscache_Consist _ARGS_((
  415.             Fscache_FileInfo *cacheInfoPtr, int flags, 
  416.             Fscache_Attributes *cachedAttrPtr));
  417.  
  418. extern void Fscache_SetMinSize _ARGS_((int minBlocks));
  419. extern void Fscache_SetMaxSize _ARGS_((int maxBlocks));
  420. extern void Fscache_BlocksUnneeded _ARGS_((Fs_Stream *streamPtr,
  421.                 int offset, int numBytes, Boolean objectFile));
  422. extern void Fscache_DumpStats _ARGS_((ClientData dummy));
  423. extern void Fscache_GetPageFromFS _ARGS_((time_t timeLastAccessed, 
  424.                 int *pageNumPtr));
  425.  
  426. extern void Fscache_FileInfoInit _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  427.         Fs_HandleHeader *hdrPtr, int version, Boolean cacheable,
  428.         Fscache_Attributes *attrPtr, Fscache_Backend *backendPtr));
  429. extern void Fscache_InfoSyncLockCleanup _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  430. extern Fscache_Backend *Fscache_RegisterBackend _ARGS_((
  431.         Fscache_BackendRoutines *ioProcsPtr, ClientData clientData, 
  432.         int flags));
  433. extern void Fscache_UnregisterBackend _ARGS_((Fscache_Backend *backendPtr));
  434.  
  435. extern void Fscache_FetchBlock _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  436.         int blockNum, int flags, Fscache_Block **blockPtrPtr, 
  437.         Boolean *foundPtr));
  438. extern void Fscache_IODone _ARGS_((Fscache_Block *blockPtr));
  439. extern void Fscache_UnlockBlock _ARGS_((Fscache_Block *blockPtr, 
  440.         time_t timeDirtied, int diskBlock, int blockSize, 
  441.         int flags));
  442. extern void Fscache_BlockTrunc _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  443.         int blockNum, int newBlockSize));
  444.  
  445. extern void Fscache_Init _ARGS_((int blockHashSize));
  446. extern void Fscache_ZeroStats _ARGS_((void));
  447. extern int Fscache_PreventWriteBacks _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  448. extern void Fscache_AllowWriteBacks _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  449. extern Fscache_FileInfo *Fscache_GetDirtyFile _ARGS_((
  450.             Fscache_Backend *backendPtr, Boolean fsyncOnly, 
  451.             Boolean (*fileMatchProc)(), ClientData clientData));
  452. extern void Fscache_ReturnDirtyFile _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  453.         Boolean onFront));
  454. extern Fscache_Block *Fscache_GetDirtyBlock _ARGS_((
  455.         Fscache_FileInfo *cacheInfoPtr, 
  456.         Boolean (*blockMatchProc)(Fscache_Block *blockPtr, 
  457.                       ClientData clientData), 
  458.         ClientData clientData, int *lastDirtyBlockPtr));
  459. extern void Fscache_ReturnDirtyBlock _ARGS_((Fscache_Block *blockPtr,
  460.             ReturnStatus status));
  461. extern ReturnStatus Fscache_PutFileOnDirtyList _ARGS_((
  462.             Fscache_FileInfo *cacheInfoPtr, int flags));
  463. extern ReturnStatus Fscache_RemoveFileFromDirtyList _ARGS_((
  464.             Fscache_FileInfo *cacheInfoPtr));
  465.  
  466. /*
  467.  * Cache operations.  There are I/O operations, plus routines to deal
  468.  * with the cached I/O attributes like access time, modify time, and size.
  469.  */
  470.  
  471. extern ReturnStatus Fscache_Read _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  472.         int flags, register Address buffer, int offset, int *lenPtr,
  473.         Sync_RemoteWaiter *remoteWaitPtr));
  474. extern ReturnStatus Fscache_Write _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  475.         int flags,  Address buffer, int offset, int *lenPtr, 
  476.         Sync_RemoteWaiter *remoteWaitPtr));
  477. extern ReturnStatus Fscache_BlockRead _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  478.         int blockNum, Fscache_Block **blockPtrPtr, int *numBytesPtr, 
  479.         int blockType, Boolean allocate));
  480. extern ReturnStatus Fscache_Trunc _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  481.                     int length, int flags));
  482.  
  483.  
  484. extern Boolean Fscache_UpdateFile _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  485.         Boolean openForWriting, int version, Boolean cacheable, 
  486.         Fscache_Attributes *attrPtr));
  487. extern void Fscache_UpdateAttrFromClient _ARGS_((int clientID, 
  488.         Fscache_FileInfo *cacheInfoPtr,  Fscache_Attributes *attrPtr));
  489. extern void Fscache_UpdateDirSize _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  490.         int newLastByte));
  491. extern void Fscache_UpdateAttrFromCache _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  492.         Fs_Attributes *attrPtr));
  493. extern void Fscache_GetCachedAttr _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  494.         int *versionPtr, Fscache_Attributes *attrPtr));
  495. extern void Fscache_UpdateCachedAttr _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  496.         Fs_Attributes *attrPtr, int flags));
  497.  
  498.  
  499. extern Boolean Fscache_OkToScavenge _ARGS_((Fscache_FileInfo *cacheInfoPtr));
  500. extern Boolean Fscache_OkToScavengeExceptDirty _ARGS_((Fscache_FileInfo
  501.     *cacheInfoPtr));
  502.  
  503.  
  504. extern int Fscache_ReserveBlocks _ARGS_((Fscache_Backend *backendPtr, 
  505.             int numResBlocks, int numNonResBlocks));
  506.  
  507. extern void Fscache_ReleaseReserveBlocks _ARGS_((Fscache_Backend *backendPtr,
  508.             int numBlocks));
  509.  
  510. /*
  511.  * Read ahead routines.
  512.  */
  513.  
  514. extern void Fscache_ReadAheadInit _ARGS_((Fscache_ReadAheadInfo *readAheadPtr));
  515. extern void Fscache_ReadAheadSyncLockCleanup _ARGS_((
  516.             Fscache_ReadAheadInfo *readAheadPtr));
  517. extern void FscacheReadAhead _ARGS_((Fscache_FileInfo *cacheInfoPtr, 
  518.                 int blockNum));
  519.  
  520. extern void Fscache_WaitForReadAhead _ARGS_((
  521.             Fscache_ReadAheadInfo *readAheadPtr));
  522. extern void Fscache_AllowReadAhead _ARGS_((Fscache_ReadAheadInfo *readAheadPtr));
  523.  
  524. extern void FscacheReadAhead _ARGS_((Fscache_FileInfo *cacheInfoPtr,
  525.             int blockNum));
  526.  
  527.  
  528. extern void FscacheBackendIdle _ARGS_((Fscache_Backend *backendPtr));
  529. extern void FscacheFinishRealloc _ARGS_((Fscache_Block *blockPtr, 
  530.             int diskBlock));
  531.  
  532. extern void Fscache_CountBlocks _ARGS_((int serverID, int majorNumber,
  533.             int *numBlocksPtr, int *numDirtyBlocksPtr));
  534.  
  535. #endif /* _FSCACHE */
  536.  
  537.